package com.witmore.skyline.web.controller.enums;

import lombok.Getter;

/**
 * Description: WorkStatusEnum
 * Author: 豆子高
 * Date: 2025/2/27 17:26
 */
@Getter
public enum WorkStatusEnum {
    // 设备工作状态（-1:离线 0:在线 1:怠速 2:负荷）
    OFFLINE(-1, "离线"),
    ONLINE(0, "在线"),
    IDLE(1, "怠速"),
    LOAD(2, "负荷");

    private final Integer code;
    private final String name;

    WorkStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    // 根据code获取name
    public static String getNameByCode(Integer code) {
        for (WorkStatusEnum workStatusEnum : WorkStatusEnum.values()) {
            if (workStatusEnum.getCode().equals(code)) {
                return workStatusEnum.getName();
            }
        }
        return WorkStatusEnum.OFFLINE.getName();
    }
}
